<template>
  <div class="wrapper">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <img class="sculpture" src="../../../../assets/images/head.png" alt />
          <span class="welcome">
            <font size="4" face="宋体">
              <strong>{{ userInfo.realname }}：您好！欢迎进入项目申报</strong>
            </font>
          </span>
          <!-- <img class="backico" src="../../../../assets/images/backico.png" @click="back()"/> -->
          <el-button
            size="small"
            round
            style="background-image: linear-gradient(#e9f0e9, white);float:right; margin: 2px 50px 0 0;"
            @click="back()"
            >返 回</el-button
          >
        </div>
      </el-col>
    </el-row>
    <div class="formall">
      <el-row>
        <el-col :span="24">
          <div class="title">
            <font size="4.7" face="微软雅黑">
              <strong>项目申报基本信息表</strong>
            </font>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form
            style="padding-left:180px"
            :model="form"
            size="medium"
            :rules="rules"
            ref="form"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-col :span="7">
              <el-form-item label="课题名称" prop="title">
                <el-input
                  class="cell-width"
                  v-model="form.title"
                  prefix-icon="el-icon-postcard"
                  placeholder="请勿超过40个汉字"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="研究方向" prop="research_direction">
                <el-input
                  class="cell-width"
                  v-model="form.research_direction"
                  prefix-icon="el-icon-rank"
                  placeholder="请输入研究方向"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="主题词" prop="theme">
                <el-input
                  class="cell-width"
                  v-model="form.theme"
                  prefix-icon="el-icon-attract"
                  placeholder="请输入主题词，以分号隔开（至多四个）"
                ></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="7">
              <el-form-item label="项目类别" prop="type">
                <el-select
                  class="cell-width"
                  v-model.number="form.type"
                  placeholder="请选择项目申请类别"
                >
                  <el-option
                    v-for="item in options1"
                    :key="item.value"
                    :label="item.title"
                    :value="item.list_id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col :span="7">
              <el-form-item label="完成时间" prop="finish_time">
                <el-date-picker
                  class="cell-width"
                  type="date"
                  placeholder="选择日期（计划完成时间）"
                  v-model="form.finish_time"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="字数" prop="word_count">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以中文千字为单位"
                  placement="top-start"
                >
                  <el-input
                    style="width: 77%"
                    v-model.number="form.word_count"
                    prefix-icon="el-icon-document-copy"
                    placeholder="请输入最终成果字数"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(千字)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="工作单位" prop="unit">
                <el-input
                  class="cell-width"
                  v-model="form.unit"
                  prefix-icon="el-icon-school"
                  placeholder="请按单位和部门公章填写全称"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="通讯地址" prop="postal_address">
                <el-input
                  class="cell-width"
                  v-model="form.postal_address"
                  prefix-icon="el-icon-discount"
                  placeholder="请按地区名，街道名及门牌号码填写"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="邮政编码" prop="post_code">
                <el-input
                  class="cell-width"
                  v-model.number="form.post_code"
                  prefix-icon="el-icon-map-location"
                  placeholder="请填写邮编（可不填）"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="21">
              <el-tooltip
                class="item"
                effect="dark"
                content="至少勾选一项至多两项"
                placement="top-start"
              >
                <el-form-item label="预计成果形式" prop="result">
                  <el-checkbox-group
                    style="width:100%"
                    v-model="result"
                    :min="1"
                    :max="2"
                    @change="mulCheck"
                  >
                    <el-checkbox
                      v-for="item in options2"
                      :key="item.value"
                      :label="item.title"
                      :value="item.id"
                    ></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-tooltip>
            </el-col>
            <el-col :span="21">
              <el-form-item label="主要参加者" prop="major_peoples">
                <el-input
                  style="width: 50%;"
                  :disabled="true"
                  v-model="form.major_peoples"
                  prefix-icon="el-icon-user-solid"
                  placeholder="此处只显示添加的参加者姓名，具体添加个人信息请点击右边按钮"
                ></el-input>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="点击添加人员信息"
                  placement="top-start"
                >
                  <el-button
                    style="margin-left:15px"
                    type="primary"
                    icon="el-icon-plus"
                    @click="dialogFormVisible = true"
                    circle
                  ></el-button>
                </el-tooltip>
                <el-dialog
                  width="35%"
                  title="完善人员信息"
                  :visible.sync="dialogFormVisible"
                >
                  <el-form :model="formPer" ref="formPer" :rules="rulesOne">
                    <table class="content" border cellspacing="0">
                      <tr>
                        <td class="left"><span class="red">*</span>姓名</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="参与人员的姓名，请认真填写"
                            v-model="formPer.name"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>性别</td>
                        <td class="right">
                          <el-select v-model="formPer.sex">
                            <el-option value="1" selected="selected"
                              >男</el-option
                            >
                            <el-option value="2">女</el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>身份证号</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请按照身份证号格式输入"
                            v-model="formPer.idnumber"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <!-- <tr>
                        <td class="left"><span class="red">*</span>出生年月</td>
                        <td class="right">
                          <el-input type="text" placeholder="请按照1990-09-11格式输入" v-model="formPer.birth" clearable></el-input>
                        </td>
                      </tr>-->
                      <tr>
                        <td class="left"><span class="red">*</span>职称</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入职称名称"
                            v-model="formPer.jobrank"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>研究专长</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入研究专长"
                            v-model="formPer.expertise"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>承担任务</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入承担任务"
                            v-model="formPer.task"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>学历</td>
                        <td class="right">
                          <el-select
                            type="text"
                            placeholder="请选择学历"
                            v-model="formPer.edu"
                            clearable
                          >
                            <el-option
                              v-for="item in edus"
                              :key="item.value"
                              :label="item.label"
                              :value="item.label"
                            ></el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>学位</td>
                        <td class="right">
                          <el-select
                            type="text"
                            placeholder="请选择学位"
                            v-model="formPer.degree"
                            clearable
                          >
                            <el-option
                              v-for="item in degrees"
                              :key="item.value"
                              :label="item.label"
                              :value="item.label"
                            ></el-option>
                          </el-select>
                        </td>
                      </tr>
                      <tr>
                        <td class="left"><span class="red">*</span>工作单位</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请按单位和部门公章填写全称"
                            v-model="formPer.unit"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                    </table>
                  </el-form>
                  <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false"
                      >取 消</el-button
                    >
                    <el-button
                      type="primary"
                      @click="
                        dialogFormVisible = false
                        servePer(formPer, 'formPer')
                      "
                      >确 定</el-button
                    >
                  </div>
                </el-dialog>
              </el-form-item>
            </el-col>
            <el-col :span="22" class="apply_expense">经费申请</el-col>
            <el-col :span="5">
              <el-form-item label="书本费" prop="book_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.book_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  v-model="form.book_fee_basis"
                  placeholder="请输入书本费预算的依据及用途，空缺项要填“无”，下同"
                  type="textarea"
                  maxlength="200"
                  show-word-limit
                  autosize
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="数据采集费" prop="data_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.data_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.data_fee_basis"
                  placeholder="请输入数据采集费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="差旅费" prop="travel_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.travel_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="travel_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.travel_fee_basis"
                  placeholder="请输入差旅费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="会议费" prop="meeting_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.meeting_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="meeting_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.meeting_fee_basis"
                  placeholder="请输入会议费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="国际合作费" prop="international_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.international_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="international_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.international_fee_basis"
                  placeholder="请输入国际交流合作费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="设备费" prop="equipment_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.equipment_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="equipment_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.equipment_fee_basis"
                  placeholder="请输入设备费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="专家咨询费" prop="consulting_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.consulting_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="consulting_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.consulting_fee_basis"
                  placeholder="请输入专家咨询费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="劳务费" prop="labour_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.labour_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="labour_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.labour_fee_basis"
                  placeholder="请输入劳务费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="印刷费" prop="print_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.print_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="book_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.print_fee_basis"
                  placeholder="请输入印刷费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="管理费" prop="administration_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.administration_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="administration_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.administration_fee_basis"
                  placeholder="请输入管理费预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="其他支出" prop="other_fee">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="以“万元”为单位填写数字"
                  placement="top-start"
                >
                  <el-input
                    class="expense-width"
                    oninput="value=value.replace(/[^\d.]/g, '')"
                    v-model="form.other_fee"
                    placeholder="若无请填0"
                  ></el-input>
                </el-tooltip>
                <span>
                  <strong>(万元)</strong>
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="17">
              <el-form-item label="依据及用途" prop="other_fee_basis">
                <el-input
                  class="cell-width"
                  type="textarea"
                  autosize
                  v-model="form.other_fee_basis"
                  placeholder="请输入其他支出预算的依据及用途"
                  maxlength="200"
                  show-word-limit
                ></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22" class="apply_expense">申报成果介绍</el-col>
        <el-col :span="22">
          <template>
            <div class="editor">
              <!-- this.$refs.ue.getUEContent()取编辑框数据 -->
              <UE :defaultMsg="defaultMsg" :config="config" ref="ue"></UE>
            </div>
          </template>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="holder">
            <el-button type style="background-color: #eef6fd" @click="cancel()"
              >取 消</el-button
            >
            <el-button type="primary" class="btn2" @click="submitAll('form')"
              >提 交</el-button
            >
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import http from '../../../../assets/js/http.js'
import UE from '../../../ue.vue'
export default {
  // props: {},
  data() {
    var checkPostcode = (rule, value, callback) => {
      // console.log(value)
      if (value != '') {
        setTimeout(() => {
          if (!Number.isInteger(value)) {
            callback(new Error('请输入6位数字'))
          } else {
            callback()
          }
        }, 1000)
      }
    }
    return {
      userInfo: Lockr.get('userInfo'),
      editor: null,
      defaultMsg: '',
      config: {
        initialFrameWidth: null,
        initialFrameHeight: 180
      },
      dialogFormVisible: false,
      dialogTableVisible: false,
      options1: [],
      options2: [],
      edus: [
        {
          label: '博士研究生',
          value: '1'
        },
        {
          label: '硕士研究生',
          value: '2'
        },
        {
          label: '大学本科',
          value: '3'
        },
        {
          label: '大学专科',
          value: '4'
        },
        {
          label: '高中',
          value: '5'
        },
        {
          label: '其他',
          value: '6'
        }
      ],
      degrees: [
        {
          label: '博士',
          value: '1'
        },
        {
          label: '硕士',
          value: '2'
        },
        {
          label: '学士',
          value: '3'
        },
        {
          label: '其他',
          value: '4'
        }
      ],
      form: {
        title: '',
        research_direction: '',
        theme: '',
        // type: "",
        finish_time: '',
        word_count: '',
        unit: '',
        postal_address: '',
        post_code: '',
        major_peoples: '',
        book_fee: '',
        book_fee_basis: '',
        data_fee: '',
        data_fee_basis: '',
        travel_fee: '',
        travel_fee_basis: '',
        international_fee: '',
        international_fee_basis: '',
        labour_fee: '',
        labour_fee_basis: '',
        administration_fee: '',
        administration_fee_basis: '',
        print_fee: '',
        print_fee_basis: '',
        equipment_fee: '',
        equipment_fee_basis: '',
        consulting_fee: '',
        consulting_fee_basis: '',
        meeting_fee: '',
        meeting_fee_basis: '',
        other_fee: '',
        other_fee_basis: ''
      },
      result: [],
      formPer: {
        name: '',
        sex: '',
        idnumber: '',
        task: '',
        // birth: '',
        jobrank: '',
        expertise: '',
        edu: '',
        degree: '',
        unit: ''
      },
      permsgAll: [],
      permsg: {},
      rules: {
        title: [
          {
            required: true,
            message: '请输入课题名称(1-40个字符)',
            trigger: 'blur'
          },
          { min: 1, max: 40, message: '长度在 1 到 40 个字符', trigger: 'blur' }
        ],
        research_direction: [
          { required: true, message: '请输入研究方向', trigger: 'change' }
        ],
        theme: [
          {
            required: true,
            message: '请输入1-4个主题词，分号隔开',
            trigger: 'change'
          }
        ],
        finish_time: [
          { required: true, message: '请选择日期', trigger: 'change' }
        ],
        word_count: [
          {
            type: 'number',
            required: true,
            message: '请填写字数',
            trigger: 'change'
          }
        ],
        unit: [
          { required: true, message: '请填写工作单位', trigger: 'change' }
        ],
        postal_address: [
          { required: true, message: '请填写通讯地址', trigger: 'change' }
        ],
        post_code: [{ validator: checkPostcode, trigger: 'blur' }],
        major_peoples: [
          {
            required: true,
            message: '请点击右边按钮添加人员',
            trigger: 'change'
          }
        ],
        book_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        data_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        travel_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        international_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        labour_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        administration_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        print_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        equipment_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        consulting_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        meeting_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ],
        other_fee: [
          {
            type: 'number',
            required: true,
            message: '若无请填0',
            trigger: 'change'
          }
        ]
      }
    }
  },
  methods: {
    // 初始化函数
    init() {
      console.log(this.userInfo)
      this.getSelection()
    },
    // 获取下拉框
    getSelection() {
      let data = {}
      this.apiPost('admin/Report/DropdowmList', data).then(res => {
        this.handelResponse(res, data => {
          // this.options1 = data.support
          this.options2 = data.achievements
        })
      })
    },
    // 多选框选择数据["", ""]格式
    mulCheck(value) {
      console.log(this.result)
    },
    // 所有参加者信息逐一保存
    servePer(permsg) {
      // console.log(permsg)
      var checkResult = this.checkList(permsg, [
        {
          name: 'jobrank',
          reg: ['notnull']
        },
        {
          name: 'name',
          reg: ['notnull']
        },
        {
          name: 'sex',
          reg: ['notnull']
        },
        {
          name: 'idnumber',
          reg: ['notnull']
        },
        {
          name: 'task',
          reg: ['notnull']
        },
        {
          name: 'expertise',
          reg: ['notnull']
        },
        {
          name: 'edu',
          reg: ['notnull']
        },
        {
          name: 'degree',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        }
      ])
      // console.log(checkResult)
      if (_g.j2s(checkResult) === '{}') {
        this.form.major_peoples = ''
        // 地址指向问题，如果不创建新的对象，每次都会指向同一个对象
        let curList = JSON.parse(JSON.stringify(permsg))
        this.permsgAll.push(curList)
        this.permsgAll.forEach(element => {
          this.form.major_peoples += element.name + ' '
        })
        this.formPer = {}
        _g.toastMsg('success', '添加成功')
      } else {
        _g.toastMsg('warning', '请完善个人信息')
      }
    },
    // 提交所有信息之前的验证
    submitAll(form) {
      // 大表单验证
      this.$refs[form].validate(valid => {
        if (valid) {
          // 多选框验证
          if (this.result.length != 0) {
            // 申报成果介绍验证
            if (this.$refs.ue.getUEContent() != '') {
              this.submit()
            } else {
              _g.toastMsg('warning', '请填写申报成功介绍')
            }
          } else {
            _g.toastMsg('warning', '请选择最终成果形式')
          }
        } else {
          console.log('error submit!!')
          return false
        }
      })
      // this.submit()
    },
    // 右上角返回上一界面
    back() {
      this.$router.push({
        name: 'reproject'
      })
    },
    // 点击取消按钮当前页面刷新
    cancel() {
      this.$router.go(0)
    },
    // 提交所有信息
    submit() {
      this.timeDeal()
      let data = {
        form: this.form,
        result: this.result,
        partner: this.permsgAll,
        achievement: this.$refs.ue.getUEContent(),
        username: this.userInfo.username,
        project_id: this.$route.params.id
      }
      console.log(data)
      this.apiPost('admin/Report/TrainWrite', data).then(res => {
        this.handelResponse(res, data => {
          _g.toastMsg('success', '项目申报提交成功')
          router.push({
            name: 'detailpro',
            params: { id: this.$route.params.id }
          })
        })
      })
    },
    // 表单日期格式处理
    timeDeal() {
      let date = new Date(this.form.finish_time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.finish_time = year + '-' + month + '-' + day
    }
  },
  created() {
    _g.closeGlobalLoading()
    this.init()
  },
  watch: {
    form(newForm, oldForm) {
      console.log(newForm)
    }
  },
  computed: {},
  components: { UE },
  mounted() {},
  mixins: [http]
}
</script>
<style scoped>
.sculpture {
  height: 30px;
  width: 30px;
}
.backico {
  padding: 8px 20px 0 0;
  float: right;
  height: 20px;
  width: 20px;
}
.header {
  margin-bottom: 10px;
  background-image: linear-gradient(#e9f0e9, white);
}
.welcome {
  padding-left: 10px;
}
.title {
  background-color: #add5fe;
  border-radius: 4px 4px 0 0;
  line-height: 30px;
  margin-bottom: 30px;
}
.formall {
  background: #fff;
}
.cell-width {
  width: 90%;
}
.left {
  width: 200px;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 400px;
  padding: 4px;
}
.red {
  color: red;
  padding-right: 3px;
}
.content {
  border-color: #e8f6f9;
}
.content tr:nth-child(even) {
  background: #fff;
}
.content tr:nth-child(odd) {
  background: #f2f9ff;
}
.apply_expense {
  padding-bottom: 20px;
  font-family: '微软雅黑';
  font-weight: 800;
  text-align: center;
}
.expense-width {
  width: 70%;
}
.holder {
  text-align: center;
  margin: 20px 0 30px 0;
}
.editor {
  padding: 0 5% 0 12%;
}
</style>
